package Clase7BolitaRebotSimple;

import java.awt.Color;
import java.awt.Graphics2D;

public class Bolita {
	private static final int DIAMETRO = 25;
	private static final int VEL_X = 1;
	private static final int VEL_Y = 1;
	
	int iX, iY, iVelX, iVelY;
	private Juego JmesaJuego;

	public Bolita(Juego JmesaJuego) {
		iX = iY = 0;
		iVelX = VEL_X;
		iVelY = VEL_Y;
		this.JmesaJuego= JmesaJuego;
	}

	void movimiento() {
		if (iX + iVelX < 0)
			iVelX = VEL_X;
		if (iX + iVelX > JmesaJuego.getWidth() - DIAMETRO)
			iVelX = -VEL_X;
		if (iY + iVelY < 0)
			iVelY = VEL_Y;
		if (iY + iVelY > JmesaJuego.getHeight() - DIAMETRO)
			iVelY = -VEL_Y;

		iX += iVelX;
		iY += iVelY;
	}

	public void paint(Graphics2D g) {
		g.setColor(Color.RED);
		g.fillOval(iX, iY, DIAMETRO, DIAMETRO);
	}
}